public aspect LogAspect {
	
	// all
	pointcut callMethodsAll(): execution(public * pl.edu.agh.iosr.gamblingzone..*.*())
				|| execution(public * pl.edu.agh.iosr.gamblingzone..*.*(*, ..));
	// dao
	pointcut callMethodsDAO(): execution(public * pl.edu.agh.iosr.gamblingzone.dao..*.*())
				|| execution(public * pl.edu.agh.iosr.gamblingzone.dao..*.*(*, ..));
	// actions
	pointcut callMethodsAction(): execution(public * pl.edu.agh.iosr.gamblingzone.action..*.*())
				|| execution(public * pl.edu.agh.iosr.gamblingzone.action..*.*(*, ..));
	// adminpanel
	pointcut callMethodsAdminpanel(): execution(public * pl.edu.agh.iosr.gamblingzone.adminpanel..*.*())
				|| execution(public * pl.edu.agh.iosr.gamblingzone.adminpanel..*.*(*, ..));
	// commons
	pointcut callMethodsCommons(): execution(public * pl.edu.agh.iosr.gamblingzone.comons..*.*())
				|| execution(public * pl.edu.agh.iosr.gamblingzone.commons..*.*(*, ..));
	// mainpanel
	pointcut callMethodsMainpanel(): execution(public * pl.edu.agh.iosr.gamblingzone.mainpanel..*.*())
				|| execution(public * pl.edu.agh.iosr.gamblingzone.mainpanel..*.*(*, ..));
	// userpanel
	pointcut callMethodsUserpanel(): execution(public * pl.edu.agh.iosr.gamblingzone.userpanel..*.*())
				|| execution(public * pl.edu.agh.iosr.gamblingzone.userpanel..*.*(*, ..));
	// utils
	pointcut callMethodsUtils(): execution(public * pl.edu.agh.iosr.gamblingzone.utils..*.*())
				|| execution(public * pl.edu.agh.iosr.gamblingzone.utils..*.*(*, ..));
	// model
	pointcut callMethodsModel(): execution(public * pl.edu.agh.iosr.gamblingzone.model..*.*()) 
				|| execution(public * pl.edu.agh.iosr.gamblingzone.model..*.*(*, ..));
	
	// DataGenerator
	pointcut callDataGenerator(): execution(* pl.edu.agh.iosr.gamblingzone.commons.DataGenerator.*()) 
				|| execution(public * pl.edu.agh.iosr.gamblingzone.commons.DataGenerator.*(*, ..));
	
	pointcut callMethods(): callMethodsAll() && !callMethodsModel() && !callMethodsDAO();
//	pointcut callMethods(): callMethodsAll() && !cflow(callDataGenerator()); //TODO
	
	before(): callMethods() {
		String arguments = "";
		for (Object a: thisJoinPoint.getArgs()) {
			if (a != null) {
				arguments += a.toString()+", ";
			}
		}
		
		String outStr = thisJoinPoint.toString().replace("execution(", "");
		outStr = outStr.substring(0, outStr.length()-1);
		if ("".equals(arguments)) {
			System.out.println("Entering: \t"+outStr);
		} else {
			System.out.println("Entering: \t"+outStr+" values ("+arguments+")");
		}
	}
	
	after() returning(Object returned): callMethods() {
		
		String outStr = thisJoinPoint.toString().replace("execution(", "");
		outStr = outStr.substring(0, outStr.length()-1);
		
		if (returned != null) {
			System.out.println("Exiting: \t"+outStr+" returned : "+returned.toString());
		} else {
			System.out.println("Exiting: \t"+outStr);
		}
	}
}
